package com.liwen.kefu.test;

import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author: Liwen
 * @createTime: 2024/11/8
 * @description:
 */
public class Case {

    /**
     * 计算两个时间差的耗时，输出 时分秒
     */
    @Test
    public void tt() throws InterruptedException {

        Date date = new Date();

        String startTime = "2024-11-01 12:10:04";
        String endTime = "2024-11-01 19:02:04";

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        Thread.sleep(1000*10);
        ZonedDateTime endZdt = ZonedDateTime.now();

        LocalDateTime dateTime1Obj = LocalDateTime.parse(startTime, formatter);
        LocalDateTime dateTime2Obj = LocalDateTime.parse(endTime, formatter);

        Duration duration = Duration.between(dateTime1Obj, dateTime2Obj);

        long totalSeconds = duration.getSeconds();

        long hours = totalSeconds / 3600;
        long minutes = (totalSeconds % 3600) / 60;
        long seconds = totalSeconds % 60;

        System.out.println(hours + "小时" + minutes + "分" + seconds + "秒");




    }


}
